<layout name="master"/>
    <ol class="breadcrumb" style="background-color: #f9f9f9;padding:8px 0;margin-bottom:10px;">
        <li>
            <a href=""><i class="fa fa-cogs"></i>
                品牌管理</a>
        </li>
        <li class="active">
            <a href="">品牌添加</a>
        </li>
    </ol>
    <ul class="nav nav-tabs" role="tablist">
        <li><a href="">品牌管理</a></li>
        <li class="active"><a href="">品牌添加</a></li>
    </ul>
    <form class="form-horizontal" id="form"  action="" method="post" enctype="multipart/form-data" >
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">品牌管理</h3>
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">品牌名称</label>
                    <div class="col-sm-9">
                        <input type="text" name="bname" value="{$oldData['bname']}" class="form-control" placeholder="品牌名称">
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">品牌logo</label>
                    <div class="col-sm-2">
                        <script src="__PUBLIC__/uploadify/jquery.uploadify.min.js"></script>
                        <link rel="stylesheet" href="__PUBLIC__/uploadify/uploadify.css">
                        <input type="file" name="file_upload" id="file_upload" />
                    </div>
                    <div class="col-sm-6 log-img">
                        <if condition="$oldData['blogo']">
                        <span>
                            <img width="150" src="__ROOT__/{$oldData['blogo']}">
                            <input type="hidden" name="blogo" value="{$oldData['blogo']}">
                            <a href="javascript:;" onclick="delImg(this)" path="{$oldData['blogo']}">X</a>
                        </span>
                        </if>
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">排序</label>
                    <div class="col-sm-9">
                        <input type="text" name="bsort" value="{$oldData['bsort']}"  class="form-control" placeholder="排序，输入整数">
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">是否热门</label>
                    <div class="col-sm-9">
                            <label class="checkbox-inline">
                                <input type="radio" name="bhot" value="1" <if condition="$oldData['bhot'] == 1">checked</if> >热门
                                &nbsp;
                                <input type="radio" name="bhot" value="2" <if condition="$oldData['bhot'] == 2">checked</if> >不热门
                            </label>
                    </div>
                </div>
            </div>
        </div>
        <button class="btn btn-primary" type="submit">确定</button>
    </form>
<script>
    $(function() {
        $("#file_upload").uploadify({
            "buttonText" : "选择品牌logo",
            'height'        : '30',
            'swf'           : '__PUBLIC__/uploadify/uploadify.swf',
            'uploader'      : "{:U('admin/brand/upload')}",
            'width'         : '120',
            'removeTimeout' : '0.1',
            'onUploadSuccess' : function(file, data, response) {
                console.log(data);
                str = '<span>';
                str += '<img width="150" src="__ROOT__/'+data+'">';
                str += '<input type="hidden" name="blogo" value="'+data+'">';
                str += '<a href="javascript:;" onclick="delImg(this)" path="'+data+'">X</a>';
                str += '</span>';
                $('.log-img').append(str);
            }
        });

    });
    function delImg(obj)
    {
        var path = $(obj).attr('path');
        $.post("{:u('admin/brand/delImg')}",{path:path},function(res){
            $(obj).parent('span').remove();
        },'json')
    }
</script>
